<?php

declare(strict_types=1);

namespace App\Service;

/**
 * Class DeliveryRuleService
 * @package App\Service
 */
class DeliveryRuleService extends BaseService
{
    /**
     * 运费模板规则
     * @param array $tpl_ids
     * @return array
     */
    public function getTplRules(array $tpl_ids): array
    {
        $rules = $this->getModelInstance()
            ->whereIn('tpl_id', '=', $tpl_ids)
            ->get();
        return empty($rules) ? [] : $rules->toArray();
    }

    /**
     * 获取地区运费规则
     * @param int $rule_id
     * @return array
     */
    public function getRuleById(int $rule_id): array
    {
        $rule = $this->getModelInstance()->find($rule_id);
        return empty($rule) ? [] : $rule->toArray();
    }
}